package com.fitso.model.bean;

import java.io.Serializable;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;

public class Address extends ModelBean implements Comparable<Address>, Serializable {
	// Only change on breaking changes, i.e., removing fields
	private static final long serialVersionUID = 1L;
	
	/* Topeka */
	private String _city;

	/* USA */
	private Country _country;

	/* 66601 */
	private String _postalCode;

	/* 123 Main St. */
	private String _prime;

	/* Kansas */
	private String _state;

	/* Suite 10 */
	private String _sub;

	public Address() {}

	public Address(String prime, String city, String state, String postalCode, Country country) {
		_prime = prime;
		_city = city;
		_state = state;
		_postalCode = postalCode;
		_country = country;
	}

	public Address(String prime, String sub, String city, String state, String postalCode, Country country) {
		_prime = prime;
		_sub = sub;
		_city = city;
		_state = state;
		_postalCode = postalCode;
		_country = country;
	}

	public int compareTo(Address other) {
		return new CompareToBuilder().append(_prime, other._prime).append(_sub, other._state)
				.append(_city, other._city).append(_state, other._state).append(_postalCode, other._postalCode).append(
						_country, other._country).toComparison();
	}

	public boolean equals(Object o) {
		if (o == null) {
			return false;
		}
		if (o == this) {
			return true;
		}
		if (o.getClass() != getClass()) {
			return false;
		}

		Address other = (Address) o;
		return new EqualsBuilder().append(_prime, other._prime).append(_sub, other._sub).append(_city, other._city)
				.append(_state, other._state).append(_postalCode, other._postalCode).append(_country, other._country)
				.isEquals();
	}

	public String getCity() {
		return _city;
	}

	public Country getCountry() {
		return _country;
	}

	public String getPostalCode() {
		return _postalCode;
	}

	public String getPrime() {
		return _prime;
	}

	public String getState() {
		return _state;
	}

	public String getSub() {
		return _sub;
	}

	public int hashCode() {
		return new HashCodeBuilder().append(_prime).append(_sub).append(_city).append(_state).append(_postalCode)
				.append(_country).toHashCode();
	}

	public void setCity(String city) {
		_city = city;
	}

	public void setCountry(Country country) {
		_country = country;
	}

	public void setPostalCode(String postalCode) {
		_postalCode = postalCode;
	}

	public void setPrime(String prime) {
		_prime = prime;
	}

	public void setState(String state) {
		_state = state;
	}

	public void setSub(String sub) {
		_sub = sub;
	}

	public String toString() {
		return new ReflectionToStringBuilder(this).toString();
	}
}
